class Magic():
    def __init__(self, required_level=1, mp_cost=0, hp=0, accurate=True):
        self.required_level = required_level
        self.mp_cost = mp_cost
        self.hp = hp
        self.accurate = accurate
        
    def attacked(self, target):
        pass
        
    def cast(self, target):
        pass
            
            
class HealthMagic(Magic):
    
    def cast(self, target):
        if target.hp <= target.mhp / 2: 
            target.hp += self.hp * 2
        else:
            target.hp += self.hp
        if target.hp >= target.mhp:
            target.hp = target.mhp
        
        
class ChunGeMagic(Magic):
    
    def __init__(self):
        Magic.__init__(self, 5)
        self.hp = 0
        
    def cast(self, target):
        target.defend_magics.append(self)
        
    def attacked(self, target):
        target.hp = target.mhp
    
class PhoneJieMagic(Magic):
    def __init__(self):
        Magic.__init__(self)
        self.hp = -999
        
    def cast(self, target):
        if target:
            target.hp = 0
        
    